package cn.jtfadmin.base.lang.config.statuscode;

import cn.jtfadmin.base.lang.config.WebConfig;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
 * 状态描述
 *
 * @author jtf
 * @see StatusCodeConfig
 * @see StatusCodeManager
 * @see WebConfig#configureHandlerExceptionResolvers(List)
 * @since 0.0.1
 */
public class StatusDescribe implements Serializable, Comparable<StatusDescribe> {
    /**
     * 错误描述
     */
    private String describe;

    /**
     * 错误码
     */
    private Integer statusCode;

    public StatusDescribe(String describe, Integer statusCode) {
        this.describe = describe;
        this.statusCode = statusCode;
    }

    public StatusDescribe() {
    }

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }

    public Integer getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(Integer statusCode) {
        this.statusCode = statusCode;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(statusCode);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj instanceof StatusDescribe) {
            return Objects.equals(((StatusDescribe) obj).statusCode, statusCode);
        }
        return false;
    }

    @Override
    public int compareTo(StatusDescribe o) {
        if (o == null) {
            return 1;
        } else {
            return getStatusCode().compareTo(o.getStatusCode());
        }
    }
}
